const path = require('path')
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  mode: 'production',
  optimization: {        
    minimize: false,        
    minimizer: [new TerserPlugin({
        extractComments: false, // To avoid separate file with licenses.
        terserOptions: {
            mangle: true,
            sourceMap: false,       
            keep_classnames: true,
            keep_fnames: true,
            toplevel: true,                                
        },                     
    })],
},
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel-loader'
      },
    ]
  },
  // externals : {
  //   cascadium: 'cascadium',
  // },
  resolve: { extensions: ["*", ".js", ".jsx"] },
  output: {
    path: path.resolve(__dirname, 'dist/'),
    publicPath: '/dist/',
    filename: 'index.js',
    libraryTarget: 'commonjs2',
  },
}